package impl

import (
	"database/sql"

	v1 "gitee.com/lcc_dr/restful-api-demo/api/book/v1"
	"gitee.com/lcc_dr/restful-api-demo/apps"
	"gitee.com/lcc_dr/restful-api-demo/conf"
	"github.com/infraboard/mcube/logger"
	"github.com/infraboard/mcube/logger/zap"
)

// var _ host.HostService = (*HostServiceImpl)(nil)
//  初始化HostService的实现
var implbook = &BookServiceImpl{}

func NewBookServiceImpl() *BookServiceImpl {
	return &BookServiceImpl{
		l:    zap.L().Named("mysql-book"),
		data: conf.GetConf().MySQL.GetDB(),
		// 	l:    l,
		// 	data: data,
	}
}

// 实现了interface HostService 接口 ，又实现了app 中 ServiceImpl接口
type BookServiceImpl struct {
	l    logger.Logger
	data *sql.DB
	v1.UnimplementedServiceServer
}

func (h *BookServiceImpl) Config() {

	h.l = zap.L().Named("book")
	h.data = conf.GetConf().MySQL.GetDB()
}

func (h *BookServiceImpl) Name() string {

	return AppName

}

// _ import  init 注册到 IOC
func init() {

	apps.RegistryBookImpl(implbook)
}
